package org.longs.converter.parser;

import org.longs.bean.PalRGB;

import java.awt.*;
import java.util.stream.IntStream;

public class NormalPixelsParser implements Parser {

    @Override
    public boolean judge(int flag) {
        return flag >> 6 == 1;
    }

    @Override
    public void analysis(Recorder recorder, BufferedColorListener result) {
        recorder.setFlag("NormalPixels");
        IntStream.range(0, (recorder.getByte() & 63))
                .mapToObj(i -> recorder.getPalRGBs()[recorder.getBytes()[recorder.getOffsetUp()] & 0xFF])
                .forEach(color -> result.result(new Color(color.getR(), color.getG(), color.getB(),255), recorder));
    }

}
